package org.example.pingpong.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.pingpong.common.PictureUp.PictureUp;
import org.example.pingpong.domain.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Api(tags = "06.图片上传接口")
@RestController
public class PictureController {

    @Autowired
    PictureUp pictureUp;

    /**
     * 上传图像接口
     *
     * @param file 上传的文件
     * @return 上传结果
     */
    @ApiOperation("上传图像接口")
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {
        return Result.success(pictureUp.upload(file));
    }
}
